package com.bang.sgg.springboot02mybatis.controller;

import com.bang.sgg.springboot02mybatis.persist.model.User;
import com.bang.sgg.springboot02mybatis.persist.model.mapper.RobotMapperExt;
import com.bang.sgg.springboot02mybatis.persist.model.mapper.UserMapperExt;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: UserController
 * @author: BANG
 * @Date: 2019/11/20 12:44
 * @Version: 1.0
 * @Modified By:
 * @Desc: TODO
 */
@RestController
@Slf4j
public class UserController {

    @Autowired
    private UserMapperExt userMapperExt;


    @Autowired
    private RobotMapperExt robotMapperExt;

    @GetMapping("/get/{userId}")
    public Object getUser(@PathVariable("userId") Long userId) {
        log.debug("参数:userId=[{}]", userId);
        log.debug("=======================================================");
        User user = userMapperExt.selectByPrimaryKey(userId);
        log.debug("返回值:user=[{}]", user);
        return user;
    }

    @GetMapping("/getOne/{userId}")
    public Object getOne(@PathVariable("userId") Long userId) {
        log.debug("参数:userId=[{}]", userId);
        log.debug("=======================================================");
        User user = robotMapperExt.getOne(userId);
        log.debug("返回值:user=[{}]", user);
        return user;
    }
}
